package com.site.util.Interceptor;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.StrutsStatics;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.site.util.constant.Constants;

/**
 * 后台用户登陆验证
 * @author lee 2012-10-10
 *
 */
public class BackendLoginInterceptor extends AbstractInterceptor{
	private static final long serialVersionUID = 1;

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
//		//System.out.println("-----------后台用户验证拦截器开始-----------");
//		ActionContext actionContext = invocation.getInvocationContext();
//		//获得request
//		HttpServletRequest request= (HttpServletRequest) actionContext.get(StrutsStatics.HTTP_REQUEST);
//		//获得session
//		Map<String, Object> session = actionContext.getSession();
//		try{
//	        if (session != null && session.get(Constants.LOGIN_USER_BACKEND) != null){
//	    		//System.out.println("-----------后台用户验证拦截器结束,用户存在,放行-----------");
//	                return invocation.invoke();
//	        }else{
//	        	request.setAttribute("messageID", "SYS_MSG_00027");
//	    		//System.out.println("-----------后台用户验证拦截器结束,用户不存在-----------");
//	        	return "loginPage2";
//	        }
//		} catch (Exception e) {
//			e.printStackTrace();
//			//System.out.println("-----------后台用户验证拦截器结束,运行异常-----------");
//			return invocation.invoke();
//		}
		
		 return invocation.invoke();
	}

}
